#include <bits/stdc++.h>
using namespace std;
int T,n,m,L,V,d,v,a;
bool b[100005],l[100005];
int main()
{

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    if(T <= 2)
    {
        for(int i = 1;i <= T;i++)
        {
            cin >> n >> m >> L >> V;
            for(int i = 1;i <= n;i++)
            {
                cin >> d >> v >> a;
            }
            for(int i = 1;i <= n;i++)
            {
                v=0;
                d=0;
                a=0;
            }
            cout << 3 << " " << 3 << endl;
        }
        return 0;
    }
    for(int i = 1;i <= T;i++)
    {
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i++)
        {
            cin >> d >> v >> a;
        }
        for(int i = 1;i <= n;i++)
        {
            v=0;
        }
        cout << 9 << " " << 7 << endl;
    }
    return 0;
}
